package com.example.demo.Controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.Random;
/**
 * @author zhang moyan
 * @date 2023/9/8 - 13:05
 */


@RestController
public class HelloController {
    @GetMapping("/hello")
    public String sayhello(){
        return "Hello world!";
    }

    @GetMapping("/random")
    public int random(){
        Random random = new Random();
        return random.nextInt(1000);
    }

    @GetMapping("/square/{number}")
    public int square(@PathVariable int number){
        return number * number;
    }

}
